package com.hula.onion.book.server.spider.platforms.wanglibao;

import com.hula.onion.book.server.common.CommonResponse;
import com.hula.onion.book.server.common.SpiderCommon;
import com.hula.onion.book.server.utils.HttpUtils;
import org.apache.http.cookie.Cookie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * Created by work on 2018/3/19.
 */
@Component("wangLiBaoSpider")
public class WangLiBaoSpider extends SpiderCommon {
    @Autowired
    private WangLiBaoSpiderHelper spiderHelper;

    private static final String LOGIN_PAGE="https://www.wanglibao.com/login/login.html";

    private static final String LOGIN_URL = "https://www.wanglibao.com/passport/service.php?c=account";

    @Override
    public CommonResponse execute() {
        HttpUtils.get(LOGIN_PAGE,getHttpContext());
        System.out.println(getHttpContext().getCookieStore().getCookies().size());
        for(Cookie c:getHttpContext ().getCookieStore().getCookies()){
            System.out.println(c.getName()+":"+c.getValue());
        }
        String loginStr = HttpUtils.post(LOGIN_URL,
                spiderHelper.installRequestParams(loginForm),
                getHttpContext());
        System.out.println(loginStr);
        return null;
    }
}
